#include <bits/stdc++.h>
using namespace std;
#include <atcoder/twosat>
using namespace atcoder;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, d;
int a[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> d;
  vector<int> x(n), y(n);
  rep(i, 0, n - 1) cin >> x[i] >> y[i];
  // ts[i] = (i-th flag is located on x[i])
  two_sat ts(n);
  rep(i, 0, n - 1) rep(j, i + 1, n - 1) {
    if (abs(x[i] - x[j]) < d) ts.add_clause(i, false, j, false);
    if (abs(x[i] - y[j]) < d) ts.add_clause(i, false, j, true);
    if (abs(y[i] - x[j]) < d) ts.add_clause(i, true, j, false);
    if (abs(y[i] - y[j]) < d) ts.add_clause(i, true, j, true);
  }
  if (!ts.satisfiable())
    cout << "No";
  else {
    cout << "Yes" << endl;
    auto ans = ts.answer();
    rep(i, 0, n - 1) cout << (ans[i] ? x[i] : y[i]) << endl;
  }
  return 0;
}